package com.xxx.controller;

import javax.servlet.http.HttpServletResponse;

import org.springframework.boot.autoconfigure.web.ErrorController;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * 错误页面
 */
@Controller
public class ExceptionController implements ErrorController {

	private static final String ERROR_PATH = "/error";

	@RequestMapping(value = ERROR_PATH)
	public String handleError(HttpServletResponse response) {
		if (response.getStatus() == 404) {
			return "error/404";
		} else if (response.getStatus() == 500) {
			return "error/500";
		}
		return "error/404";
	}

	@Override
	public String getErrorPath() {
		return ERROR_PATH;
	}

}
